//
//  MUserModel.m
//  Index
//
//  Created by Apple－12 on 15/10/27.
//  Copyright (c) 2015年 Apple－12. All rights reserved.
//

#import "MUserModel.h"

@implementation MUserModel

- (id)init
{
    self = [super init];
    if (self) {
        self.isLoginIndex = 0;
    }
    return self;
}
- (id)initWithJSON: (id)JSON {
    
    if ([JSON isKindOfClass:[NSDictionary class]] && JSON) {
        
        self.alipayAccount = [self dataHandleWithObj:JSON[@"AlipayAccount"]];
        self.loginName = [self dataHandleWithObj:JSON[@"LoginName"]];
        self.loginPwd = [self dataHandleWithObj:JSON[@"LoginPwd"]];
        self.name = [self dataHandleWithObj:JSON[@"Name"]];
        self.ID = [self dataHandleWithObj:JSON[@"ID"]];
        self.email = [self dataHandleWithObj:JSON[@"Email"]];
        self.point = [self dataHandleWithObj:JSON[@"Points"]];
        self.regTime = [self dataHandleWithObj:JSON[@"RegTime"]];
        self.tel = [self dataHandleWithObj:JSON[@"Tel"]];
        self.userType = [self dataHandleWithObj:JSON[@"UserType"]];
        self.money = [self dataHandleWithObj:JSON[@"Money"]];
        self.mobliePhone = [self dataHandleWithObj:JSON[@"MobliePhone"]];
        self.coins = [self dataHandleWithObj:JSON[@"Coins"]];
        self.area = [self dataHandleWithObj:JSON[@"Area"]];
        self.areaID = [self dataHandleWithObj:JSON[@"AreaID"]];
        self.city = [self dataHandleWithObj:JSON[@"City"]];
        self.cityID = [self dataHandleWithObj:JSON[@"CityID"]];
        self.province = [self dataHandleWithObj:JSON[@"Province"]];
        self.provinceID = [self dataHandleWithObj:JSON[@"ProvinceID"]];
        self.checkState = [self dataHandleWithObj:JSON[@"CheckState"]];
        self.lastLogin = [self dataHandleWithObj:JSON[@"LastLogin"]];
        self.lastLoginIP = [self dataHandleWithObj:JSON[@"LastLoginIP"]];
        self.loginTimes = [self dataHandleWithObj:JSON[@"LoginTimes"]];
        
        
    }
    return self;
}
- (NSString *)dataHandleWithObj:(id)obj {
    if ([obj isKindOfClass:[NSNumber class]]) {
        return [(NSNumber *)obj stringValue];
    } else if ([obj isKindOfClass:[NSString class]]) {
        
        return (obj == [NSNull null]) ? @"" : obj;
    } else {
        
        return @"";
    }
    
}
- (void)encodeWithCoder:(NSCoder *)coder {
    
    if (coder) {
        [coder encodeObject:self.alipayAccount forKey:@"AlipayAccount"];
        [coder encodeObject:self.area forKey:@"Area"];
        [coder encodeObject:self.areaID forKey:@"AreaID"];
        [coder encodeObject:self.checkState forKey:@"CheckState"];
        [coder encodeObject:self.city forKey:@"City"];
        [coder encodeObject:self.cityID forKey:@"CityID"];
        [coder encodeObject:self.coins forKey:@"Coins"];
        [coder encodeObject:self.email forKey:@"Email"];
        [coder encodeObject:self.ID forKey:@"ID"];
        [coder encodeObject:self.lastLogin forKey:@"LastLogin"];
        [coder encodeObject:self.lastLoginIP forKey:@"LastLoginIP"];
        [coder encodeObject:self.loginName forKey:@"LoginName"];
        [coder encodeObject:self.loginPwd forKey:@"LoginPwd"];
        [coder encodeObject:self.loginTimes forKey:@"LoginTimes"];
        [coder encodeObject:self.money forKey:@"Money"];
        [coder encodeObject:self.name forKey:@"Name"];
        [coder encodeObject:self.point forKey:@"Points"];
        [coder encodeObject:self.province forKey:@"Province"];
        [coder encodeObject:self.provinceID forKey:@"ProvinceID"];
        [coder encodeObject:self.regTime forKey:@"RegTime"];
        [coder encodeObject:self.tel forKey:@"Tel"];
        [coder encodeObject:self.userType forKey:@"UserType"];
        [coder encodeObject:self.mobliePhone forKey:@"MobliePhone"];
    }
}
- (id)initWithCoder:(NSCoder *)coder {
    
    self = [super init];
    
    if (self && coder) {
        self.alipayAccount = [coder decodeObjectForKey:@"AlipayAccount"];
        self.area = [coder decodeObjectForKey:@"Area"];
        self.areaID = [coder decodeObjectForKey:@"AreaID"];
        self.checkState = [coder decodeObjectForKey:@"CheckState"];
        self.city = [coder decodeObjectForKey:@"City"];
        self.cityID = [coder decodeObjectForKey:@"CityID"];
        self.coins = [coder decodeObjectForKey:@"Coins"];
        self.email = [coder decodeObjectForKey:@"Email"];
        self.lastLogin = [coder decodeObjectForKey:@"LastLogin"];
        self.lastLoginIP = [coder decodeObjectForKey:@"LastLoginIP"];
        self.loginName = [coder decodeObjectForKey:@"LoginName"];
        self.loginPwd = [coder decodeObjectForKey:@"LoginPwd"];
        self.loginTimes = [coder decodeObjectForKey:@"LoginTimes"];
        self.name = [coder decodeObjectForKey:@"Name"];
        self.point = [coder decodeObjectForKey:@"Points"];
        self.province = [coder decodeObjectForKey:@"Province"];
        self.provinceID = [coder decodeObjectForKey:@"ProvinceID"];
        self.regTime = [coder decodeObjectForKey:@"RegTime"];
        self.tel = [coder decodeObjectForKey:@"Tel"];
        self.userType = [coder decodeObjectForKey:@"UserType"];
        self.money = [coder decodeObjectForKey:@"Money"];
        self.mobliePhone = [coder decodeObjectForKey:@"MobliePhone"];
    }
    return self;
}

@end
